$(function() {
    var a = {
            index: "http://preorder.oneplus.net/index.html",
            load: "http://preorder.oneplus.net/ajax/load",
            getStates: "http://preorder.oneplus.net/ajax/state",
            calculateShipPrice: "http://preorder.oneplus.net/ajax/price",
            save: "http://preorder.oneplus.net/ajax/order",
            getOrder: "http://preorder.oneplus.net/ajax/info",
            login: "http://preorder.oneplus.net/login",
            staticRoot: "http://a.onepluscontent.com",
            count: "http://preorder.oneplus.net/ajax/count",
            error: "http://preorder.oneplus.net/error.html",
            timeout: "http://preorder.oneplus.net/timeout.html",
            seeyou: "http://preorder.oneplus.net/seeyou.html"
        },
        b = {
            phoneSku: "0101020602",
            unit: "$",
            currentCountryCode: cookieTools.getItem("isoCode") || "US",
            nextPage: "check.html",
            flagRoot: a.staticRoot + "/skin/frontend/oneplus2014/default/images/flags/",
            statusFlag: "1"
        },
        c = function() {
            var b = $("#countDown"),
                c = b.find(".js-title"),
                d = b.find(".js-day"),
                e = b.find(".js-hour"),
                f = b.find(".js-min"),
                g = b.find(".js-sec"),
                i = 1e3,
                j = 60 * i,
                k = 60 * j,
                l = 24 * k;
            return {
                init: function(m) {
                    if (this.counting && clearInterval(this.counting), 2 == m.flag && (c.text("Pre-orders will end in"), b.find(".js-day-ele").remove()), 3 == m.flag) return void(window.location.href = a.seeyou);
                    var n = 1e3 * m.timestamp,
                        o = Date.now() + n;
                    this.counting = setInterval(function() {
                        var a = Date.now(),
                            b = o - a;
                        return 300 > b ? void h.changeStatus() : (d.text(("00" + Math.floor(b / l)).slice(-2)), e.text(("00" + Math.floor(b % l / k)).slice(-2)), f.text(("00" + Math.floor(b % k / j)).slice(-2)), void g.text(("00" + Math.floor(b % j / i)).slice(-2)))
                    }, 300)
                }
            }
        }(),
        d = function() {
            var c = $("#sectionOne"),
                d = $("#address"),
                f = ($(".js-country"), $("#productList")),
                h = $("#shippingInfo"),
                i = $("#billingInfo"),
                j = $("#inputShipFirstname"),
                k = $("#inputShipLastname"),
                l = $("#inputShipCompany"),
                m = $("#inputShipAddress1"),
                n = $("#inputShipAddress2"),
                o = $("#inputShipCity"),
                p = $("#inputShipState"),
                q = $("#inputShipZip"),
                r = $("#inputShipCountry"),
                s = $("#inputShipTelephone"),
                t = $("#inputBillFirstname"),
                u = $("#inputBillLastname"),
                v = $("#inputBillCompany"),
                w = $("#inputBillAddress1"),
                x = $("#inputBillAddress2"),
                y = $("#inputBillCity"),
                z = $("#inputBillState"),
                A = $("#inputBillZip"),
                B = $("#inputBillCountry"),
                C = $("#inputBillTelephone"),
                D = $("#sameAsShippingAddress"),
                E = $("#shippingMethodsContainer"),
                F = null,
                G = null;
            D.on("change", function() {
                this.checked ? $("#billingInfo").hide() : $("#billingInfo").show()
            }), q.on("blur", function() {
                e.$itself.trigger("change")
            }), B.on("change", function() {
                $.ajax({
                    url: a.getStates,
                    data: {
                        format: "json",
                        isoCode: B.val()
                    },
                    type: "post",
                    dataType: "json",
                    success: function(a) {
                        if (0 === a.ret) switch (L(a.data), B.val()) {
                            case "US":
                                A.data().rule = "UsZip";
                                break;
                            case "GB":
                                A.data().rule = "UkZip", z.removeClass("to-validate");
                                break;
                            default:
                                A.data().rule = "NotEmpty"
                        }
                    }
                })
            }), f.on("click", "i.js-product", function() {
                var a = $(this);
                a.addClass("selected"), a.siblings().removeClass("selected"), $parent = a.parents("tr"), $parent.find("img")[0].src = a.data().imgsrc, $parent.find(".js-name").text(a.data().name), $parent.find(".js-name")[0].href = a.data().link
            }), f.on("mouseenter", "i.js-product", function() {
                var a = $(this);
                $parent = a.parents("tr"), $parent.find("img")[0].src = a.data().imgsrc, $parent.find(".js-name").text(a.data().name), $parent.find(".js-name")[0].href = a.data().link
            }), f.on("mouseleave", ".color-selection, .desc-selection", function() {
                var a = $(this);
                $parent = a.parents("tr");
                var b = a.find(".selected");
                $parent.find("img")[0].src = b.data().imgsrc, $parent.find(".js-name").text(b.data().name), $parent.find(".js-name")[0].href = b.data().link
            }), f.on("click", ".js-add-to-cart", function() {
                var a = $(this),
                    b = a.parents(".js-product.selected");
                b.length || (b = $(this).parents("tr").find(".js-product.selected")), e.addToCart(b.data(), !0, function() {
                    a.data().timeout && clearTimeout(a.data().timeout), a.tooltip("show"), a.data().timeout = setTimeout(function() {
                        a.tooltip("hide")
                    }, 1e3)
                })
            }), E.on("click", "[name=inputShippingMethod]", function() {
                this.checked && (G = $(this), e.$itself.trigger("change"))
            }), $(".form-group").on("blur", ".form-control.to-validate:visible", function() {
                var a = $(this),
                    b = a.data().rule;
                b && (Validator["is" + b](a.val()) ? (a.siblings(".on-error").hide(), a.parents(".form-group").removeClass("has-error")) : (a.siblings("p.on-error").text(Validator.errMsg), a.siblings(".on-error").show(), a.parents(".form-group").addClass("has-error")))
            }), k.on("blur", function() {
                H(k) && I(j, k, "isNameMax35")
            }), n.on("blur", function() {
                I(m, n, "isAddressMax128")
            }), u.on("blur", function() {
                D[0].checked || H(u) && I(t, u, "isNameMax35")
            }), x.on("blur", function() {
                D[0].checked || I(w, x, "isAddressMax128")
            });
            var H = function(a) {
                    var b = a.data().rule;
                    if (b) return Validator["is" + b](a.val()) ? (a.siblings(".on-error").hide(), a.parents(".form-group").removeClass("has-error"), !0) : (a.siblings("p.on-error").text(Validator.errMsg), a.siblings(".on-error").show(), a.parents(".form-group").addClass("has-error"), !1)
                },
                I = function(a, b, c) {
                    var d = (a.val() || "") + " " + (b.val() || "");
                    return Validator[c](d) ? (b.siblings(".on-error").hide(), a.parents(".form-group").removeClass("has-error"), b.parents(".form-group").removeClass("has-error"), !1) : (b.siblings("p.on-error").text(Validator.errMsg), b.siblings(".on-error").show(), a.parents(".form-group").addClass("has-error"), b.parents(".form-group").addClass("has-error"), !0)
                },
                J = function(a) {
                    for (var c = "", d = 0; d < a.length; d++) {
                        var f = a[d];
                        if (f.sku != b.phoneSku) {
                            var g = "";
                            g = f.subclass ? $("#series_product_tplt").html() : $("#single_product_tplt").html(), c += _.template(g)({
                                product: f,
                                unit: b.unit
                            })
                        } else e.setPhonePrice((f.price*0.803077393), $(".phone-main .js-unit").html(b.unit), $(".phone-main .js-price").text((f.price*0.803077393) - 0).toFixed(0))
                    }
                    $("#productList tbody").html(c)
                },
                K = function(a) {
                    for (var c = a.bill_country, d = a.bill_state, e = a.ship_state, f = "", g = 0; g < c.length; g++) f += '<option value="' + c[g].isoCode + '">' + c[g].name + "</option>";
                    B.empty(), B.append($(f)), B.val(b.currentCountryCode), L(d), M(e);
                    var h = a.ship_method;
                    switch (h && (E.html(_.template($("#shipping_radio_tpt").html())({
                        shipMethods: h
                    })), F = E.find("[name=inputShippingMethod]"), G = E.find("[name=inputShippingMethod]:checked")), b.currentCountryCode) {
                        case "TW":
                            $(".bg-warning.on-tw").show();
                            break;
                        case "US":
                            q.data().rule = "UsZip", A.data().rule = "UsZip";
                            break;
                        case "GB":
                            q.data().rule = "UkZip", A.data().rule = "UkZip", p.removeClass("to-validate");
                            break;
                        default:
                            q.data().rule = "NotEmpty", A.data().rule = "NotEmpty"
                    }
                },
                L = function(a) {
                    var b = $("#bill_states_tpt");
                    z.replaceWith(_.template(b.html())({
                        billStates: a
                    })), z = $("#inputBillState")
                },
                M = function(a) {
                    var b = $("#ship_states_tpt");
                    p.replaceWith(_.template(b.html())({
                        shipStates: a
                    })), p = $("#inputShipState")
                },
                N = function(a) {
                    if (a.cart_list && a.cart_list.products && !_.isEmpty(a.cart_list.products)) {
                        var b = new Date(1e3 * a.cart_list.time || Date.now()),
                            d = c.find(".saved-order");
                        d.find(".js-order-time").text(b.toUTCString().split(", ")[1]), d.show()
                    }
                    if (a.cart_list && a.cart_list.method) {
                        var e = E.find('input[value="' + a.cart_list.method + '"]');
                        e.attr("checked", !0)
                    }
                    if (a.address) {
                        var f = a.address.ship_addr;
                        f && (j.val(f.firstName || ""), k.val(f.lastName || ""), l.val(f.company || ""), m.val(f.street1 || ""), n.val(f.street2 || ""), o.val(f.city || ""), p.val("INPUT" == p[0].nodeName.toUpperCase() ? f.stateName || "" : f.state || ""), q.val(f.zip || ""), s.val(f.telephone || ""), D.attr("checked", f.type && 3 == f.type), D.trigger("change"));
                        var g = a.address.bill_addr;
                        if (g) switch (t.val(g.firstName || ""), u.val(g.lastName || ""), v.val(g.company || ""), w.val(g.street1 || ""), x.val(g.street2 || ""), y.val(g.city || ""), z.val("INPUT" == z[0].nodeName.toUpperCase() ? g.stateName || "" : g.state || ""), A.val(g.zip || ""), B.val(g.country || ""), C.val(g.telephone || ""), g.state) {
                            case "US":
                            case "UK":
                                A.data().rule = "UsZip";
                                break;
                            case "GB":
                                A.data().rule = "UkZip", z.removeClass("to-validate");
                                break;
                            default:
                                A.data().rule = "NotEmpty"
                        }
                    }
                },
                O = function(a) {
                    1 != a.flag && (c.find(".js-title").text("Make your choice"), c.find(".js-desc").text("The time has come. Select what youâ€™d like to pre-order, including a range of OnePlus accessories at a special offer."))
                };
            return {
                init: function(a) {
                    K(a), J(a.allskus), N(a), O(a.status)
                },
                changeStatus: O,
                getAddressInfo: function() {
                    var a = {};
                    a.firstName = j.val() || "", a.lastName = k.val() || "", a.company = l.val() || "", a.street1 = m.val() || "", a.street2 = n.val() || "", a.city = o.val() || "", "INPUT" == p[0].nodeName.toUpperCase() ? a.stateName = p.val() : (a.state = p.val() || "", a.stateName = p.find("option:selected").text() || ""), a.zip = q.val() || "", a.country = r.data().code || "", a.countryName = r.val() || "", a.telephone = s.val() || "";
                    var b = G.val() || "",
                        c = G.data().name || "",
                        d = D[0].checked || !1,
                        e = {};
                    return e.firstName = t.val() || "", e.lastName = u.val() || "", e.company = v.val() || "", e.street1 = w.val() || "", e.street2 = x.val() || "", e.city = y.val() || "", "INPUT" == z[0].nodeName.toUpperCase() ? e.stateName = z.val() : (e.state = z.val() || "", e.stateName = z.find("option:selected").text() || ""), e.zip = A.val() || "", e.country = B.val() || "", e.countryName = B.find("option:selected").text() || "", e.telephone = C.val() || "", {
                        ship_addr: a,
                        ship_method: b,
                        ship_name: c,
                        same_addr: d,
                        bill_addr: e
                    }
                },
                loadShipCountry: function(a) {
                    r.attr("value", a.name), r.data().name = a.name, r.data().code = a.code
                },
                clearShippingAddress: function() {
                    j.val(""), k.val(""), l.val(""), m.val(""), n.val(""), o.val(""), p.val(""), q.val(""), s.val("")
                },
                reset: function() {
                    d[0].reset(), $("#billingInfo").hide()
                },
                getAllProducts: function() {
                    return $(".js-product")
                },
                validate: function() {
                    var a = !0,
                        b = "",
                        c = function(c) {
                            var d = c.data().rule;
                            d && (Validator["is" + d](c.val()) ? (c.siblings(".on-error").hide(), c.parents(".form-group").removeClass("has-error")) : (c.siblings("p.on-error").text(Validator.errMsg), c.siblings(".on-error").show(), c.parents(".form-group").addClass("has-error"), b || (b = "#" + c[0].id), a = !1))
                        },
                        d = function(c, d, e) {
                            var f = (c.val() || "") + " " + (d.val() || "");
                            Validator[e](f) ? (d.siblings(".on-error").hide(), c.parents(".form-group").removeClass("has-error"), d.parents(".form-group").removeClass("has-error")) : (d.siblings("p.on-error").text(Validator.errMsg), d.siblings(".on-error").show(), c.parents(".form-group").addClass("has-error"), d.parents(".form-group").addClass("has-error"), b || (b = "#" + c[0].id), a = !1)
                        };
                    d(j, k, "isNameMax35"), d(m, n, "isAddressMax128");
                    for (var e = h.find(".form-control.to-validate"), f = 0; f < e.length; f++) {
                        var l = $(e[f]);
                        c(l)
                    }
                    if (!D[0].checked) {
                        d(t, u, "isNameMax35"), d(w, x, "isAddressMax128");
                        for (var e = i.find(".form-control.to-validate"), f = 0; f < e.length; f++) {
                            var l = $(e[f]);
                            c(l)
                        }
                    }
                    var o = g.validatePassCode(b, a);
                    return b = o.anchor, a = o.isValid, b && $("html,body").animate({
                        scrollTop: $(b).offset().top - 20 + "px"
                    }, "fast"), a
                },
                fetchShippingZipAndMethod: function() {
                    var a = {};
                    return a.post_code = q.val() || "", a.ship_method = G.val() || "", a.ship_name = G.data().name || "", a
                }
            }
        }(),
        e = function() {
            var a = $("#billSummary"),
                c = a.find(".js-countries ul"),
                g = ($("#ready"), a.find(".js-unit")),
                h = $("#priceSum");
            a.on("change", function() {
                e.changeShippingPrice()
            }), a.on("click", ".js-remove", function() {
                var b = $(this).parents("tr");
                return b.remove(), a.trigger("change"), !1
            }), c.on("click", ".js-country", function() {
                var a = $(this);
                cookieTools.setItem("isoCode", a.data().code || "US"), window.location.reload()
            });
            var i = function(a) {
                    for (var e = "", f = 0; f < a.length; f++) {
                        var g = a[f].isoCode;
                        e += '<li role="presentation"><a class="js-country" role="menuitem" tabindex="-1" data-code="' + g + '"" data-name="' + a[f].name + '"><img src="' + b.flagRoot + g.toLowerCase() + '.png" alt="' + g + '" /> <small>' + a[f].name + "</small></a></li>"
                    }
                    c.empty(), c.append($(e));
                    var h = $(".js-country[data-code=" + b.currentCountryCode + "]");
                    $("#selectCountry img")[0].src = h.find("img")[0].src, d.loadShipCountry(h.data())
                },
                j = function(c, d, e) {
                    var f = a.find("#" + c.sku),
                        g = c.count || 1;
                    if (f.length) {
                        var h = $("#" + c.sku).find(".js-count");
                        h.val() < 2 ? (h.val(2), d && a.trigger("change")) : e && e()
                    } else {
                        var i = '<tr class="js-bill-item js-change" id="' + c.sku + '" data-sku="' + c.sku + '" data-weight="' + c.weight + '" data-imgsrc="' + c.imgsrc + '"><td class="col-md-8"><label class="js-name">' + c.name + '</label></td><td class="col-md-2"><select class="js-count"><option value="1">1</option><option value="2" ' + (2 == g ? "selected" : "") + '>2</option></select></td><td class="text-right col-md-2"><div class="text-right"><span class="js-unit">' + b.unit + '</span><span class="js-price">' + (c.price*0.803077393) + '</span></div><div class="margin-tiny"></div><a class="text-muted js-remove"href="#">remove</a></td></tr>';
                        a.find(".summary-data table").append($(i)), d && a.trigger("change")
                    }
                },
                k = function(c) {
                    var e = c.cart_list;
                    e.isoCode != b.currentCountryCode && d.clearShippingAddress();
                    for (var f = d.getAllProducts(), i = {}, k = 0; k < f.length; k++) {
                        var l = $(f[k]);
                        i[l.data().sku] = l.data()
                    }
                    g.html(b.unit);
                    var m = e.products;
                    if (!m) return void a.trigger("change");
                    for (var k = 0; k < m.length; k++) {
                        var n = m[k];
                        if (n.sku != b.phoneSku) {
                            var o = i[n.sku];
                            o && (o.count = n.num, j(o))
                        } else {
                            var p = $(".js-phone .js-count");
                            p.val(n.num)
                        }
                    }
                    var q = $("#shippingItem");
                    e.ship_name && q.find(".js-name").text(e.ship_name), e.shipFee && q.find(".js-price").text((e.shipFee - 0 || 0).toFixed(2)), e.totalFee && h.text((e.totalFee - 0 || 0).toFixed(2))
                },
                l = function(b) {
                    var c = b.flag;
                    1 == c && (a.find(".js-reminder").show(), a.find(".js-save").hide()), 2 == c && (a.find(".js-reminder").hide(), a.find(".js-save").show(), a.find("p:first").hide()), 3 == c && (a.find(".js-reminder").remove(), a.find(".js-save").remove(), a.find("p:first").hide())
                };
            return {
                $itself: a,
                init: function(a) {
                    var b = a.ship_country;
                    i(b), k(a), l(a.status)
                },
                changeStatus: l,
                addToCart: j,
                setPhonePrice: function(a) {
                    this.$itself.find(".js-phone .js-price").text(a)
                },
                changeShippingPrice: function() {
                    var a = d.fetchShippingZipAndMethod();
                    a.products = this.getCartInfo();
                    var b = {};
                    if (a.post_code) b = f.calculate(a);
                    else {
                        b.subtotal = 0;
                        for (var c = 0; c < a.products.length; c++) b.subtotal += a.products[c].num * a.products[c].price*0.803077393;
                        b.postage = 0, a.ship_name = "uncalculated"
                    }
                    var e = $("#shippingItem");
                    e.find(".js-name").text(a.ship_name), e.find(".js-price").text(b.postage.toFixed(2)), h.text(b.subtotal.toFixed(2))
                },
                getCartInfo: function() {
                    for (var a = this.$itself.find(".js-bill-item"), b = [], c = 0; c < a.length; c++) {
                        var d = $(a[c]),
                            e = {};
                        e.sku = d.data().sku, e.num = d.find(".js-count").val(), e.name = d.find(".js-name").text(), e.price = (d.find(".js-price")*0.803077393).text(), e.weight = d.data().weight, e.img = d.data().imgsrc, b.push(e)
                    }
                    return b
                },
                clear: function() {
                    $(".js-bill-item.js-change").remove(), this.$itself.trigger("change")
                }
            }
        }(),
        f = function() {
            var a = [];
            return {
                init: function(c) {
                    for (var d = 0; d < c.length; d++) {
                        var e = c[d];
                        e.dest_country_id == b.currentCountryCode && a.push(e)
                    }
                },
                calculate: function(b) {
                    var c = 0,
                        d = 0;
                    if (b.products && !_.isEmpty(b.products)) {
                        for (var e = b.products, f = 0, g = 0; g < e.length; g++) d += e[g].num * (e[g].price*0.803077393), f += e[g].num * e[g].weight;
                        for (var g = 0; g < a.length; g++) {
                            var h = a[g];
                            if (h.delivery_type == b.ship_method && (h.condition_from_value <= f && f <= h.condition_to_value && (c = (h.price*0.803077393)), b.post_code && h.dest_zip && h.dest_zip_to)) {
                                if (h.dest_zip > b.post_code) continue;
                                if (h.dest_zip_to < b.post_code) continue;
                                if (h.condition_from_value <= f && f <= h.condition_to_value) {
                                    c = (h.price*0.803077393);
                                    break
                                }
                            }
                        }
                        return c || (c = 300), c -= 0, d += c, {
                            postage: c,
                            subtotal: d
                        }
                    }
                }
            }
        }(),
        g = function() {
            return $saveSection = $("#saveSection"), $save = $(".js-save"), $clear = $("#clear"), $success = $("#successInfo"), $timeout = $("#timeoutInfo"), $passCodeSection = $("#passCodeSection"), $passCodeImg = $("#passCodeSection img"), $passCodeImg.on("click", function() {
                h.changeStatus()
            }), $passCodeSection.find("input").on("keydown", function(a) {
                13 == a.keyCode && $($save[0]).trigger("click")
            }), $success.on("click", "button", function() {
                var a = (new Date, $("#sectionOne .saved-order"));
                a.text("This is your recently saved pre-order."), a.show(), $("html,body").animate({
                    scrollTop: "0px"
                }, "fast")
            }), $save.on("click", function(c) {
                if (c.preventDefault(), c.stopPropagation(), !d.validate()) return !1;
                var f = d.getAddressInfo();
                return f.products = e.getCartInfo(), f.passcode = $passCodeSection.find("#passCode:visible").val(), $save.attr("disabled", !0), "1" == b.statusFlag && setTimeout(function() {
                    $save.attr("disabled", !1)
                }, 3e3 * Math.random()), $(".loading-mask").show(), $.ajax({
                    url: a.save,
                    data: {
                        format: "json",
                        order: f
                    },
                    type: "post",
                    dataType: "json",
                    success: function(c) {
                        return setTimeout(function() {
                            switch ($(".loading-mask").hide(), "2" == b.statusFlag && $save.attr("disabled", !1), c.ret) {
                                case 0:
                                    if (1 == c.data.flag) {
                                        $success.modal("show");
                                        var d = e.getCartInfo();
                                        ga("create", "UA-46480385-11", "auto"), ga("require", "ec");
                                        for (var f = 0; d > f; f++) {
                                            var g = d[f];
                                            ga("ec:addProduct", {
                                                id: g.sku,
                                                name: g.name,
                                                brand: "OnePlus",
                                                price: (g.price*0.803077393),
                                                quantity: g.num - 0
                                            })
                                        }
                                        return ga("ec:setAction", "checkout", {
                                            step: b.statusFlag,
                                            id: c.data.orderSn || cookieTools.getItem("userId"),
                                            affiliation: "OnePlus One pre-order",
                                            revenue: $("#priceSum").text(),
                                            shipping: $("#shippingItem .js-price").text()
                                        }), ga("send", "pageview"), !1
                                    }
                                    if (2 == c.data.flag) {
                                        var i = c.data.orderSn;
                                        return window.location.href = b.nextPage + "?sn=" + i, !1
                                    }
                                    break;
                                case 1:
                                    window.location.href = a.login;
                                    break;
                                case 3:
                                    $passCodeSection.find(".on-error").show(), $("html,body").animate({
                                        scrollTop: $("#passCode").offset().top - 20 + "px"
                                    }, "fast"), h.changeStatus()
                            }
                        }, 1e3), !1
                    },
                    timeout: 3e4,
                    error: function(a, c) {
                        setTimeout(function() {
                            $(".loading-mask").hide(), "2" == b.statusFlag && $save.attr("disabled", !1), h.changeStatus(), "timeout" == c ? $("#timeoutInfo").modal("show") : $("#errorInfo").modal("show")
                        }, 1e3)
                    }
                }), !1
            }), $clear.on("click", function() {
                return d.reset(), e.clear(), !1
            }), {
                init: function(c) {
                    if (b.statusFlag = c.flag, 2 == c.flag) {
                        $save.text("continue"), $saveSection.find(".js-title").text("Let's Rock"), $saveSection.find(".js-line-one").text("Your OnePlus One is now one step closer to you. When youâ€™re ready, hit continue to get your estimated shipping time."), $saveSection.find(".js-line-two").text("Note that once your pre-order is placed, you will not be able to modify the contents of your cart under any circumstance.");
                        var d = $saveSection.find("#passCodeSection");
                        d.find("img").attr("src", a.staticRoot + "/img/passcode/" + c.code + ".png"), d.show()
                    }
                    3 == c.flag && $saveSection.remove()
                },
                validatePassCode: function(a, b) {
                    var c = $passCodeSection.find("#passCode:visible");
                    return c.length > 0 && (Validator.isNotEmpty(c.val()) ? c.siblings(".on-error").hide() : ($passCodeSection.find(".on-error").show(), h.changeStatus(), a || (a = "#passCode"), b = !1)), {
                        anchor: a,
                        isValid: b
                    }
                }
            }
        }(),
        h = function() {
            return $.ajax({
                type: "POST",
                url: a.load,
                dataType: "json",
                success: function(h) {
                    if ($(".loading-mask").hide(), 0 === h.ret) {
                        var i = {
                            GBP: "ï¿¡",
                            USD: "$",
                            SEK: "SEK",
                            DKK: "DKK",
                            HKD: "HKD",
                            TWD: "TWD",
                            EUR: "&#x20AC;"
                        };
                        b.unit = i[h.data.allskus[0].unit], g.init(h.data.status), f.init(h.data.shipping), c.init(h.data.status), d.init(h.data), e.init(h.data)
                    }
                    1 == h.ret && (window.location.href = a.login)
                },
                timeout: 3e4,
                error: function(a, b) {
                    $(".loading-mask").remove(), "timeout" == b ? $("#timeoutInfo").modal("show") : $("#errorInfo").modal("show")
                }
            }), addthisevent.settings({
                license: "a1tffjumpzkv7044hmv2",
                css: !1
            }), {
                changeStatus: function() {
                    $.ajax({
                        type: "POST",
                        url: a.count,
                        dataType: "json",
                        success: function(b) {
                            if (0 == b.ret) {
                                var f = b.data;
                                c.init(f), d.changeStatus(f), e.changeStatus(f), g.init(f)
                            }
                            1 == b.ret && (window.location.href = a.login)
                        }
                    })
                }
            }
        }()
});